﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ClassLib.UserControl.DanhMuc;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraSplashScreen;
using ISumen;
using Sumen.Business;
using Sumen.Business.Model.Presenter.Sys;
using Sumen_Stock.LookAndFeel.Sumen_System;

namespace Sumen_Stock.LookAndFeel.Category
{
    public partial class Frm_Stock : DevExpress.XtraEditors.XtraForm
    {
        private FromCode _fromCode = FromCode.FrmStock;
        public Frm_Stock()
        {
            InitializeComponent();
            ucDanhMuc1.mySetValidate = new UCDanhMuc.setValidate(myValidate);
            //if (ClsPublic.Writelog == "1")
            //{
            //    SysLogPresenter log = new SysLogPresenter();
            //    log.Add(_fromCode, EnumFormStatus.View, "", "");
            //}
        }
        public override void Refresh()
        {
            SplashScreenManager.ShowForm(typeof(WaitForm1));
            base.Refresh();
            ucDanhMuc1.reLoad();
            ucDanhMuc1.reLoadParent();
            SplashScreenManager.CloseForm();
        }


        public void myValidate(GridView gridView, ValidateRowEventArgs e)
        {
            try
            {
                e.Valid = ucDanhMuc1.Check_NULL(gridView, "stock_id", "Không được rỗng");
                if (!e.Valid) return;
                e.Valid = ucDanhMuc1.Check_NULL(gridView, "stock_name", "Không được rỗng");
                if (!e.Valid) return;
                e.Valid = ucDanhMuc1.Check_NULL(gridView, "stock_CodeInward", "Không được rỗng");
                if (!e.Valid) return;
                e.Valid = ucDanhMuc1.Check_NULL(gridView, "stock_CodeOutward", "Không được rỗng");
                if (!e.Valid) return;
            }
            catch
            {

            }
        }

        private void Frm_Stock_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (ClsPublic.Writelog == "1" && ucDanhMuc1.IsSave)
            {
                SysLogPresenter log = new SysLogPresenter();
                log.Add(_fromCode, EnumFormStatus.Modify, "", "");
            }
        }






    }
}